package com.gack.business.model;


import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.gack.helper.common.abstractobj.IdEntity;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
@Entity
@Table(name="sensitiveword")
public class SensitiveWord extends IdEntity{
	private String sensitivewordName;
	@Temporal(TemporalType.TIMESTAMP)
	private Date create_time;
	
	
	public String getSensitivewordName() {
		String specialChar="!@#$%^&*()_+=-~`,./<>?|{}[]，。？；‘：“”【】）（*&……%￥#@！~·";
		String str="";
		for (int i = 0; i < sensitivewordName.length(); i++) {
			char word = sensitivewordName.charAt(i);
			if(specialChar.indexOf(word+"")>0){
				continue;
			}
			str+=word;
		}
		return str;
	}

	public void setSensitivewordName(String sensitivewordName) {
		this.sensitivewordName = sensitivewordName;
	}
	
	/**
     * set<User></>去重，重新如下两个方法hashCode、equals
     */
    @Override
    public int hashCode(){
        return sensitivewordName.hashCode();
    }
 
    @Override
    public boolean equals(Object obj){
        if(obj instanceof SensitiveWord){
        	SensitiveWord sensitiveWord=(SensitiveWord)obj;
            return this.getSensitivewordName().equals(sensitiveWord.getSensitivewordName());
        }
        return super.equals(obj);
    }
	
}
